import http from '@/utils/http'

/**
 * 获取预付订单列表
 */
export const getMemberOrderPre = () => {
    return http({ url: '/member/order/pre' });
};

/**
 * 创建订单
 * @param {Object} data 创建订单用到的数据
 */
export const postMemberOrder = (data) => {
    return http({ url: '/member/order', method: 'post', data });
};

/**
 * 根据订单id来查阅订单详情
 * @param {String} id 订单id
 */
export const getMemberOrderById = (id) => {
    return http({ url: `/member/order/${id}`, method: 'get' });
};

/**
 * 传递订单id来获取微信支付的参数
 * @param {String} orderId 订单id
 */
export const getPayWxPayMiniPay = (orderId) => {
    return http({ url: `/pay/wxPay/miniPay`, method: 'get', data: { orderId } });
};

/**
 * 传递订单id 来模拟真正的微信支付
 * @param {String} orderId 订单id
 */
export const getPayMock = (orderId) => {
    return http({ url: `/pay/mock`, method: 'get', data: { orderId } });
};

/**
 * 获取订单列表
 * @param {Object} data page-页码 pageSize-页容量  orderState-订单状态，0全部订单、1为待付款、2为待发货、3为待收货、4为待评价、5为已完成、6为已取消，未传该参数或0为全部
 */
export const getMemberOrder = (data) => {
    return http({ url: `/member/order`, data });
};

/**
 * 立即购买获取在的订单信息
 * @param {Object} data skuId-商品skuId count-数量 addressld-商品地址
 */
export const getMemberOrderPreNow = (data) => {
    return http({ url: `/member/order/pre/now`, data });
};